#include "popmainwnd.h"
#include "ui_popmainwnd.h"
#include "listitem.h"
#include <QDebug>

PopMainWnd::PopMainWnd(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::PopMainWnd)
{
    ui->setupUi(this);
    setWindowFlags(windowFlags() | Qt::Tool | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint);
    setAttribute(Qt::WA_NoSystemBackground);
    setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明
    QPalette pal = palette();
    pal.setColor(QPalette::Background, Qt::transparent);
    setPalette(pal);

//    ui->listWidget->setAttribute(Qt::WA_TranslucentBackground, true);//背景透明
//    QPalette pa2 = ui->listWidget->palette();
//    pa2.setColor(QPalette::Background, Qt::transparent);
//    ui->listWidget->setPalette(pa2);

//    ui->labelBk->raise();

    //
    showListItem();
}

PopMainWnd::~PopMainWnd()
{
    delete ui;
}

void PopMainWnd::showListItem()
{
    ui->listWidget->clear();

    QRect rc = this->geometry();
    rc.setHeight(90 * 5);
    this->setGeometry(rc);

    for (int i = 0; i < 5; ++i) {
        ListItem* listItem = new ListItem(this);
        QListWidgetItem* item = new QListWidgetItem();
        QRect rcWidget = listItem->geometry();
        item->setSizeHint(QSize(rcWidget.width(), rcWidget.height()));
        ui->listWidget->addItem(item);
        ui->listWidget->setItemWidget(item, listItem);
    }
}
